package com.dfl.launcher;

import android.os.Handler;
import android.os.Looper;

import androidx.annotation.WorkerThread;

import com.dfl.api.app.guistore.SkinInfo;

/**
 * 模拟具体的换肤管理器
 */
public class MockSkinManager {
    private static MockSkinManager instance;

    public static MockSkinManager getInstance() {
        if (instance == null) {
            synchronized (MockSkinManager.class) {
                if (instance == null) {
                    instance = new MockSkinManager();
                }
            }
        }
        return instance;
    }

    @WorkerThread
    public void changeSkinSuccessCase(SkinInfo skinInfo, ResultCallback<ChangeResult> callback) {
        //  模拟换肤成功
        new Handler(Looper.getMainLooper()).postDelayed(() -> {
            // 切换至主线程
            final ChangeResult result = new ChangeResult.Success(skinInfo);
            callback.onResult(result);
        }, 1000);
    }

    @WorkerThread
    public void changeSkinFailureCase(SkinInfo skinInfo, ResultCallback<ChangeResult> callback) {
        //  模拟换肤失败
        new Handler(Looper.getMainLooper()).postDelayed(() -> {
            // 切换至主线程
            final ChangeResult result = new ChangeResult.Failure(skinInfo, new IllegalStateException("failure reason"));
            callback.onResult(result);
        }, 1000);
    }

}
